// Copyright (c) 2005  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of cgal-python; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with cgal-python.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Id: Py_Iso_rectangle_2.cpp 167 2007-11-02 15:36:54Z spion $
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal-python/trunk/cgal-python/bindings/Kernel/Py_Iso_rectangle_2.cpp $
//
// Author(s)     : Naceur Meskini
//=========================================================================
//
#include <CGAL/basic.h>
#include <include/Kernels.h>

#include <boost/python.hpp>
#include <boost/cstdint.hpp>

const char* Iso_rectangle_2_doc[]={
"An object s of the data type Iso_cuboid_3 is a rectangle in the Euclidean plane E x E\n\
with sides parallel to the x and y axis of the coordinate system.\n\
Although they are represented in a canonical form by only two vertices, \n\
namely the lower left and the upper right vertex, we provide functions for ``accessing'' \n\
the other vertices as well. The vertices are returned in counterclockwise order.\n\
Iso-oriented rectangles and bounding boxes are quite similar. \n\
The difference however is that bounding boxes have always double coordinates, \n\
whereas the coordinate type of an iso-oriented rectangle is chosen by the user. \n\
For more details see a C++ documentation:\n\
http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Kernel_23_ref/Class_Iso_rectangle_2.html",

"r = Iso_rectangle_2( Point_2 p, Point_2 q)\n\
introduces an iso-oriented rectangle r with diagonal opposite vertices p and q. \n\
Note that the object is brought in the canonical form.\n\n\
r = Iso_rectangle_2( Point_2 left,Point_2 right,Point_2 bottom,Point_2 top)\n\
introduces an iso-oriented rectangle r whose minimal x coordinate is the one of left, the maximal x coordinate \n\
is the one of right, the minimal y coordinate is the one of bottom, the maximal y coordinate is the one of top\n\n\
r = Iso_rectangle_2( min_hx,min_hy,min_hz,max_hx,max_hy,hw = 1)\n\
introduces an iso-oriented rectangle r with diagonal opposite vertices (min_hx/hw, min_hy/hw) and (max_hx/hw, max_hy/hw).\n\
Precondition: hw # 0.",

"r.min(self) -> Point_2\nreturns the smallest vertex of r (= vertex(0)).",

"r.max(self) -> Point_2\nreturns the largest vertex of r (= vertex(7)).",

"r.vertex(self,int i) -> Point_2\nreturns the i'th vertex modulo 8 of r. starting with the lower left vertex.",

"r.transform(self, Aff_transformation_3 t) -> Iso_cuboid_3\n\
returns the iso-oriented rectangle obtained by applying t on the smallest and the largest of r.\n\
Precondition: The angle at a rotation must be a multiple of pi/2, otherwise the resulting \n\
rectangle does not have the same size. Note that rotating about an arbitrary angle can even result\n\
in a degenerate iso-oriented rectangle.",

"r.bounded_side(self,Point_2 p) -> Bounded_side\n\
returns either ON_UNBOUNDED_SIDE, ON_BOUNDED_SIDE, or the constant ON_BOUNDARY, depending on where point p is.",

"r.has_on_boundary(self,Point_2 p) ->bool",

"r.has_on_bounded_side(self,Point_2 p) ->bool",

"r.has_on_unbounded_side(self,Point_2 p) ->bool",

"r.is_degenerate(self) ->bool\nc is degenerate, if all vertices are collinear.",

"r.bbox(self) -> Bbox\nreturns a bounding box containing r. ",

"r.xmin(self) -> double\nreturns smallest Cartesian x-coordinate in r.",
"r.ymin(self) -> double\nreturns smallest Cartesian y-coordinate in r.",
"r.xmax(self) -> double\nreturns largest Cartesian x-coordinate in r.",
"r.ymax(self) -> double\nreturns largest Cartesian y-coordinate in r.",
"r.min_coord(self,int i) ->double\nreturns i-th Cartesian coordinate of the smallest vertex of r.\n\
Precondition: 0 <= i<= 2.",
"r.max_coord(self) ->double\nreturns i-th Cartesian coordinate of the largest vertex of r.\n\
Precondition: 0 <= i<= 2.",
"r.area(self) -> double\nreturns the area of r."
};

template<class kernel>
void Py_Iso_rectangle_2()
{
	typedef typename kernel::Point_2 					Point_2;
	typedef typename kernel::Segment_2 					Segment_2;
 	typedef typename kernel::Vector_2 					Vector_2;
 	typedef typename kernel::Direction_2 					Direction_2;
 	typedef typename kernel::Line_2 					Line_2;
  	typedef typename kernel::Ray_2 					        Ray_2;
 	typedef typename kernel::Triangle_2 					Triangle_2;
	typedef typename kernel::Iso_rectangle_2 				Iso_rectangle_2;
	typedef typename kernel::Circle_2 				      	Circle_2;
	typedef typename kernel::Aff_transformation_2 				Aff_transformation_2;
	typedef typename kernel::FT 						FT;
	typedef typename kernel::RT						RT;

	using namespace boost::python;

        class_< Iso_rectangle_2 >("Iso_rectangle_2", Iso_rectangle_2_doc[0], init<>())
        .def(init< const Iso_rectangle_2& >(Iso_rectangle_2_doc[1]))
        .def(init< const Point_2&, const Point_2& >())
        .def(init< const Point_2&, const Point_2&, const Point_2&, const Point_2& >())
        .def(init< const FT&, const FT&, const FT&, const FT& >())
        .def(init< const FT&, const FT&, const FT&, const FT&, const FT& >())
        .def(init< const double&, const double&, const double&, const double& >())
        .def(init< const double&, const double&, const double&, const double&, const double& >())
#if CGAL_VERSION_NR < 1030301000
        .def("min", &Iso_rectangle_2::min, by_cref(), Iso_rectangle_2_doc[2])
        .def("max", &Iso_rectangle_2::max, by_cref(), Iso_rectangle_2_doc[3])
#else
        .def("min", &Iso_rectangle_2::min, typename Value_or_cref<typename kernel::Construct_min_vertex_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[2])
        .def("max", &Iso_rectangle_2::max, typename Value_or_cref<typename kernel::Construct_max_vertex_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[3])
#endif
        .def("vertex", &Iso_rectangle_2::vertex, Iso_rectangle_2_doc[4])
	.def("transform", &Iso_rectangle_2::transform, Iso_rectangle_2_doc[5])
        .def("bounded_side", &Iso_rectangle_2::bounded_side, Iso_rectangle_2_doc[6])
        .def("has_on_boundary", &Iso_rectangle_2::has_on_boundary, Iso_rectangle_2_doc[7])
        .def("has_on_bounded_side", &Iso_rectangle_2::has_on_bounded_side, Iso_rectangle_2_doc[8])
        .def("has_on_unbounded_side", &Iso_rectangle_2::has_on_unbounded_side, Iso_rectangle_2_doc[9])
        .def("is_degenerate", &Iso_rectangle_2::is_degenerate, Iso_rectangle_2_doc[10])
        .def("bbox", &Iso_rectangle_2::bbox, Iso_rectangle_2_doc[11])
#if CGAL_VERSION_NR < 1030301000
       	.def("xmin", &Iso_rectangle_2::xmin, by_cref(), Iso_rectangle_2_doc[12])
        .def("xmax", &Iso_rectangle_2::xmax, by_cref(), Iso_rectangle_2_doc[13])
        .def("ymin", &Iso_rectangle_2::ymin, by_cref(), Iso_rectangle_2_doc[14])
        .def("ymax", &Iso_rectangle_2::ymax, by_cref(), Iso_rectangle_2_doc[15])
        .def("min_coord", &Iso_rectangle_2::min_coord, by_cref(), Iso_rectangle_2_doc[16])
        .def("max_coord", &Iso_rectangle_2::max_coord, by_cref(), Iso_rectangle_2_doc[17])
#else
       	.def("xmin", &Iso_rectangle_2::xmin, typename Value_or_cref<typename kernel::Compute_xmin_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[12])
        .def("xmax", &Iso_rectangle_2::xmax, typename Value_or_cref<typename kernel::Compute_xmax_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[13])
        .def("ymin", &Iso_rectangle_2::ymin, typename Value_or_cref<typename kernel::Compute_ymin_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[14])
        .def("ymax", &Iso_rectangle_2::ymax, typename Value_or_cref<typename kernel::Compute_ymax_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[15])
        .def("min_coord", &Iso_rectangle_2::min_coord, typename Value_or_cref<typename kernel::Compute_xmin_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[16])
        .def("max_coord", &Iso_rectangle_2::max_coord, typename Value_or_cref<typename kernel::Compute_xmin_2, Iso_rectangle_2 > ::type(), Iso_rectangle_2_doc[17])
#endif
        .def("area", &Iso_rectangle_2::area, Iso_rectangle_2_doc[18])
        .def( self == self )
        .def( self != self )
    ;
}

void export_Iso_rectangle_2()
{
	Py_Iso_rectangle_2<K>();
}
